package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.service.PurchaseListGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/purchaseListGoods")
public class PurchaseListGoodsController {

    @Autowired
    private PurchaseListGoodsService purchaseListGoodsService;

    /**
     * 进货单列表展示（可条件查询：单据号模糊、供应商、是否付款和日期区间）
     * http://localhost:8080/purchaseListGoods/list
     * @author xuzhenzhan
     * @param purchaseNumber
     * @param supplierId
     * @param state
     * @param sTime
     * @param eTime
     * @return
     */
    @PostMapping("list")
    public Map<String, Object> list(String purchaseNumber, Integer supplierId, Integer state, String sTime, String eTime) {
        return purchaseListGoodsService.list(purchaseNumber, supplierId, state, sTime, eTime);
    }

    /**
     * 查询进货单商品信息
     * http://localhost:8080/purchaseListGoods/goodsList
     * @author xuzhenzhan
     * @param purchaseListId
     * @return
     */
    @PostMapping("goodsList")
    public Map<String, Object> goodsList(Integer purchaseListId) {
        return purchaseListGoodsService.goodsList(purchaseListId);
    }

    /**
     * 进货单删除
     * http://localhost:8080/purchaseListGoods/delete
     * @param purchaseListId
     * @return
     */
    @PostMapping("delete")
    public ServiceVO delete(Integer purchaseListId) {
        return purchaseListGoodsService.delete(purchaseListId);
    }
}
